.class final Lorg/microemu/app/Common$1;
.super Ljava/lang/Thread;
.source "Common.java"


# instance fields
.field private final this$0:Lorg/microemu/app/Common;

.field private final val$common:Lorg/microemu/app/Common;

.field private final val$exitAtTheEnd:Z

.field private final val$urlString:Ljava/lang/String;


# direct methods
.method constructor <init>(Lorg/microemu/app/Common;Ljava/lang/String;Lorg/microemu/app/Common;Ljava/lang/String;Z)V
    .locals 0
    .parameter
    .parameter "x0"
    .parameter
    .parameter
    .parameter

    .prologue
    .line 253
    iput-object p1, p0, Lorg/microemu/app/Common$1;->this$0:Lorg/microemu/app/Common;

    iput-object p3, p0, Lorg/microemu/app/Common$1;->val$common:Lorg/microemu/app/Common;

    iput-object p4, p0, Lorg/microemu/app/Common$1;->val$urlString:Ljava/lang/String;

    iput-boolean p5, p0, Lorg/microemu/app/Common$1;->val$exitAtTheEnd:Z

    invoke-direct {p0, p2}, Ljava/lang/Thread;-><init>(Ljava/lang/String;)V

    return-void
.end method


# virtual methods
.method public run()V
    .locals 12

    .prologue
    .line 255
    const/4 v2, 0x1

    .line 257
    .local v2, firstJad:Z
    :goto_0
    iget-object v10, p0, Lorg/microemu/app/Common$1;->val$common:Lorg/microemu/app/Common;

    iget-object v10, v10, Lorg/microemu/app/Common;->jad:Lorg/microemu/util/JadProperties;

    invoke-virtual {v10}, Lorg/microemu/util/JadProperties;->clear()V

    .line 258
    const-string v10, "AutoTests open jad"

    iget-object v11, p0, Lorg/microemu/app/Common$1;->val$urlString:Ljava/lang/String;

    invoke-static {v10, v11}, Lorg/microemu/log/Logger;->debug(Ljava/lang/String;Ljava/lang/String;)V

    .line 260
    :try_start_0
    iget-object v10, p0, Lorg/microemu/app/Common$1;->val$common:Lorg/microemu/app/Common;

    iget-object v11, p0, Lorg/microemu/app/Common$1;->val$urlString:Ljava/lang/String;

    invoke-static {v11}, Lorg/microemu/app/Common;->access$000(Ljava/lang/String;)Lorg/microemu/util/JadProperties;

    move-result-object v11

    iput-object v11, v10, Lorg/microemu/app/Common;->jad:Lorg/microemu/util/JadProperties;
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    .line 269
    const/4 v2, 0x0

    .line 272
    iget-object v10, p0, Lorg/microemu/app/Common$1;->val$common:Lorg/microemu/app/Common;

    iget-object v10, v10, Lorg/microemu/app/Common;->jad:Lorg/microemu/util/JadProperties;

    invoke-virtual {v10}, Lorg/microemu/util/JadProperties;->getMidletEntries()Ljava/util/Vector;

    move-result-object v10

    invoke-virtual {v10}, Ljava/util/Vector;->iterator()Ljava/util/Iterator;

    move-result-object v4

    .line 273
    .local v4, it:Ljava/util/Iterator;
    invoke-interface {v4}, Ljava/util/Iterator;->hasNext()Z

    move-result v10

    if-nez v10, :cond_2

    .line 274
    const-string v10, "MIDlet Suite has no entries"

    invoke-static {v10}, Lorg/microemu/app/ui/Message;->error(Ljava/lang/String;)V

    .line 321
    .end local v4           #it:Ljava/util/Iterator;
    :goto_1
    iget-boolean v10, p0, Lorg/microemu/app/Common$1;->val$exitAtTheEnd:Z

    if-eqz v10, :cond_0

    .line 322
    const/4 v10, 0x0

    invoke-static {v10}, Ljava/lang/System;->exit(I)V

    .line 324
    :cond_0
    :goto_2
    return-void

    .line 261
    :catch_0
    move-exception v10

    move-object v1, v10

    .line 262
    .local v1, e:Ljava/io/IOException;
    if-eqz v2, :cond_1

    .line 263
    invoke-static {v1}, Lorg/microemu/log/Logger;->debug(Ljava/lang/Throwable;)V

    goto :goto_1

    .line 265
    :cond_1
    const-string v10, "AutoTests no more tests"

    invoke-static {v10}, Lorg/microemu/log/Logger;->debug(Ljava/lang/String;)V

    goto :goto_1

    .line 277
    .end local v1           #e:Ljava/io/IOException;
    .restart local v4       #it:Ljava/util/Iterator;
    :cond_2
    invoke-interface {v4}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Lorg/microemu/util/JadMidletEntry;

    .line 278
    .local v5, jadMidletEntry:Lorg/microemu/util/JadMidletEntry;
    invoke-virtual {v5}, Lorg/microemu/util/JadMidletEntry;->getClassName()Ljava/lang/String;

    move-result-object v8

    .line 280
    .local v8, midletClassName:Ljava/lang/String;
    const/4 v3, 0x1

    .line 282
    .local v3, firstJar:Z
    :goto_3
    iget-object v10, p0, Lorg/microemu/app/Common$1;->this$0:Lorg/microemu/app/Common;

    const/4 v11, 0x1

    invoke-static {v10, v11}, Lorg/microemu/app/Common;->access$100(Lorg/microemu/app/Common;Z)Lorg/microemu/app/classloader/MIDletClassLoader;

    move-result-object v7

    .line 283
    .local v7, midletClassLoader:Lorg/microemu/app/classloader/MIDletClassLoader;
    iget-object v10, p0, Lorg/microemu/app/Common$1;->this$0:Lorg/microemu/app/Common;

    iget-object v11, p0, Lorg/microemu/app/Common$1;->val$urlString:Ljava/lang/String;

    invoke-virtual {v10, v11, v3}, Lorg/microemu/app/Common;->saveJar2TmpFile(Ljava/lang/String;Z)Ljava/lang/String;

    move-result-object v9

    .line 284
    .local v9, tmpURL:Ljava/lang/String;
    if-nez v9, :cond_3

    .line 285
    const-string v10, "AutoTests no new jar"

    invoke-static {v10}, Lorg/microemu/log/Logger;->debug(Ljava/lang/String;)V

    goto :goto_0

    .line 288
    :cond_3
    const/4 v3, 0x0

    .line 291
    :try_start_1
    iget-object v10, p0, Lorg/microemu/app/Common$1;->this$0:Lorg/microemu/app/Common;

    iget-object v11, p0, Lorg/microemu/app/Common$1;->val$urlString:Ljava/lang/String;

    invoke-virtual {v10, v11, v9, v7}, Lorg/microemu/app/Common;->loadJar(Ljava/lang/String;Ljava/lang/String;Lorg/microemu/app/classloader/MIDletClassLoader;)V

    .line 292
    invoke-virtual {v7, v8}, Lorg/microemu/app/classloader/MIDletClassLoader;->loadClass(Ljava/lang/String;)Ljava/lang/Class;
    :try_end_1
    .catch Ljava/lang/ClassNotFoundException; {:try_start_1 .. :try_end_1} :catch_2

    move-result-object v6

    .line 297
    .local v6, midletClass:Ljava/lang/Class;
    const-string v10, "AutoTests start class"

    invoke-static {v10, v8}, Lorg/microemu/log/Logger;->debug(Ljava/lang/String;Ljava/lang/String;)V

    .line 298
    iget-object v10, p0, Lorg/microemu/app/Common$1;->this$0:Lorg/microemu/app/Common;

    invoke-static {}, Lorg/microemu/MIDletBridge;->getMIDletAccess()Lorg/microemu/MIDletAccess;

    move-result-object v11

    invoke-static {v10, v6, v11}, Lorg/microemu/app/Common;->access$200(Lorg/microemu/app/Common;Ljava/lang/Class;Lorg/microemu/MIDletAccess;)Lorg/microemu/MIDletContext;

    move-result-object v0

    .line 300
    .local v0, context:Lorg/microemu/MIDletContext;
    invoke-static {}, Lorg/microemu/MIDletBridge;->getMIDletContext()Lorg/microemu/MIDletContext;

    move-result-object v10

    if-ne v10, v0, :cond_4

    .line 301
    iget-object v10, p0, Lorg/microemu/app/Common$1;->this$0:Lorg/microemu/app/Common;

    invoke-static {v10}, Lorg/microemu/app/Common;->access$300(Lorg/microemu/app/Common;)Ljava/lang/Object;

    move-result-object v10

    monitor-enter v10

    .line 303
    :try_start_2
    iget-object v11, p0, Lorg/microemu/app/Common$1;->this$0:Lorg/microemu/app/Common;

    invoke-static {v11}, Lorg/microemu/app/Common;->access$300(Lorg/microemu/app/Common;)Ljava/lang/Object;

    move-result-object v11

    invoke-virtual {v11}, Ljava/lang/Object;->wait()V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0
    .catch Ljava/lang/InterruptedException; {:try_start_2 .. :try_end_2} :catch_3

    .line 307
    :try_start_3
    monitor-exit v10
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    .line 309
    :cond_4
    :goto_4
    invoke-static {v0}, Lorg/microemu/app/util/MIDletThread;->hasRunningThreads(Lorg/microemu/MIDletContext;)Z

    move-result v10

    if-eqz v10, :cond_5

    .line 311
    const-wide/16 v10, 0x64

    :try_start_4
    invoke-static {v10, v11}, Ljava/lang/Thread;->sleep(J)V
    :try_end_4
    .catch Ljava/lang/InterruptedException; {:try_start_4 .. :try_end_4} :catch_1

    goto :goto_4

    .line 312
    :catch_1
    move-exception v1

    .line 316
    :cond_5
    const-string v10, "AutoTests ends"

    invoke-static {v10}, Lorg/microemu/log/Logger;->debug(Ljava/lang/String;)V

    goto :goto_3

    .line 293
    .end local v6           #midletClass:Ljava/lang/Class;
    .end local v0           #context:Lorg/microemu/MIDletContext;
    :catch_2
    move-exception v10

    move-object v1, v10

    .line 294
    .local v1, e:Ljava/lang/ClassNotFoundException;
    invoke-static {v1}, Lorg/microemu/log/Logger;->debug(Ljava/lang/Throwable;)V

    goto/16 :goto_0

    .line 304
    .end local v1           #e:Ljava/lang/ClassNotFoundException;
    .restart local v0       #context:Lorg/microemu/MIDletContext;
    .restart local v6       #midletClass:Ljava/lang/Class;
    :catch_3
    move-exception v11

    move-object v1, v11

    .line 305
    .local v1, e:Ljava/lang/InterruptedException;
    :try_start_5
    monitor-exit v10

    goto :goto_2

    .line 307
    .end local v1           #e:Ljava/lang/InterruptedException;
    :catchall_0
    move-exception v11

    monitor-exit v10
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_0

    throw v11
.end method
